package com.fenghuajueli.libbasecoreui.manager;

import com.fenghuajueli.lib_data.entity.db.NoteDbEntity;
import com.fenghuajueli.lib_data.entity.db.TargetDbEntity;
import com.fenghuajueli.libbasecoreui.BaseApplication;

import java.util.List;

public class NoteManager {

    private static class NoteManagerSingleton {
        private static final NoteManager INSTANCE = new NoteManager();

    }

    public static NoteManager getInstance() {
        return NoteManager.NoteManagerSingleton.INSTANCE;
    }

    private NoteManager() {
    }

    public void saveNoteDbEntity(NoteDbEntity noteDbEntity) {
        BaseApplication.getTargetDaoMaster().newSession().getNoteDbEntityDao().insertOrReplace(noteDbEntity);
    }

    public List<NoteDbEntity> deleteNoteDbEntity(NoteDbEntity noteDbEntity) {
        BaseApplication.getTargetDaoMaster().newSession().getNoteDbEntityDao().delete(noteDbEntity);
        return getNoteData();
    }

    public List<NoteDbEntity> getNoteData() {
        return BaseApplication.getTargetDaoMaster().newSession().getNoteDbEntityDao().queryBuilder().list();
    }
}
